package com.bcbim.authentication.user.mapper;

import com.bcbim.authentication_interface.user.dao.UserDAO;
import com.bcbim.authentication_interface.user.dao.UserRoleDAO;
import com.bcbim.authentication_interface.user.dto.UserDTO;
import com.bcbim.authentication_interface.user.dto.UserListDTO;
import com.bcbim.authentication_interface.user.po.User;
import com.bcbim.authentication_interface.user.vo.UserVO;
import com.bcbim.common.sys.Code;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @Description: 用户mapper
 * @Author haoshuai
 * @Date 2020/9/11
 * @Version V1.0
 **/
@Mapper
public interface UserMapper {

    /**
     * @Description: 更新最后登录时间
     * @Param: username
     * @Return:
     * @Author: ye
     * @Date: 2021/7/6
     */
    void updateLastLoginTime(String username);
    UserDTO getUserByUsername(String username);

    UserDTO getUserByNickname(String nickName);

    /**
     * @Description: 用户列表
     * @Param: UserQuery
     * @Return: List<UserVO>
     * @Author: ye
     * @Date: 2020/11/30
     */
    List<UserVO> listUser(UserListDTO userListDTO);

    /**
     * @Description: 用户总数
     * @Param: nickname
     * @Return: int
     * @Author: ye
     * @Date: 2020/11/30
     */
    int listUserCount(UserListDTO userListDTO);

    /**
     * @Description: 新建用户
     * @Param: UserDO
     * @Return: int
     * @Author: ye
     * @Date: 2020/11/30
     */
    int saveUser(UserDAO userDAO);

    /**
     * @Description: 删除用户
     * @Param: usernames
     * @Return:
     * @Author: ye
     * @Date: 2020/11/30
     */
    int removeUser(@Param("id") String id, @Param("del") String del);

    /**
     * @Description: 编辑更新用户
     * @Param: UserDO
     * @Return:
     * @Author: ye
     * @Date: 2020/11/30
     */
    int updateUser(UserDAO userDAO);

    /**
     * @Description: 用户名校验
     * @Param: username
     * @Return: int
     * @Author: ye
     * @Date: 2020/12/2
     */
    int usernameCheck(String username);

    /**
     * @Description: 清除用户角色
     * @Param: username
     * @Return:
     * @Author: ye
     * @Date: 2021/7/6
     */
    void clearUserRole(String id);

    /**
     * @Description: 保存用户角色信息
     * @Param: List<RoleUserDO>
     * @Return:
     * @Author: ye
     * @Date: 2021/7/6
     */
    void saveUserRole(@Param("list") List<UserRoleDAO> list);

    /**
     * @return List<Code>
     * @Description 查询所有角色
     * @Author XueHao
     * @Date 2021/8/23
     */
    List<Code> selectRole(String roleName);

    /**
     * 重置密码
     *
     * @param id       id
     * @param password password
     * @return int
     * @author XueHao
     * @date 2021/12/2
     */
    int resetPassword(@Param("id") String id, @Param("password") String password);

    /**
     * 查询用户详情
     *
     * @param id id
     * @return UserVO
     * @author XueHao
     * @date 2022/1/14
     */
    UserVO getUser(String id);

    /**
     * 检查旧密码
     *
     * @param id
     * @param oldPassword
     * @author xuehao
     * @createDate 2022/3/16 14:00
     * @retuen int
     */
    int checkOldPassword(@Param("id") String id, @Param("password") String oldPassword);

    /**
     * 查询用户拥有的平台
     *
     * @param userId
     * @author xuehao
     * @createDate 2022/3/18 9:38
     * @retuen String
     */
    List<Code> selectApplicationPlatformByUserId(String userId);

    /**
     * @Description: 查询用户角色
     * @Param: username
     * @Return: ReturnMsg
     * @Author: ye
     * @Date: 2021/7/6
     */
    List<Code> getUserRole(String userId);

    /**
     * 判断用户角色数量
     *
     * @param roleId
     * @author xuehao
     * @createDate 2022/4/18 15:13
     * @retuen int
     */
    int checkRoleCount(String roleId);
}
